{% extends "theme_base.html" %}

{% load i18n %}
{% load ifsetting_tag %}
{% load dajaxice_templatetags %}


{% block head_title %}{% trans "Collection List" %}{% endblock %}
{% block extra_head%}
    <script src="{{ STATIC_URL }}js/jquery.dataTables.min.js"></script>
    <link href="{{ STATIC_URL }}css/jquery.dataTables.css" rel="stylesheet"></link>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
    <link href="{{ STATIC_URL }}css/ui-darkness/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
    {% dajaxice_js_import %}
    <script type="text/javascript">
        $(document).ready(function() {
        $('#col-table').dataTable({
            "bJQueryUI": true,
            //"sPaginationType": "full_numbers",
            "sScrollX": "100%",
            "sScrollXInner": "110%",
            "bScrollCollapse": true
            //"sDom": '<"top"i>rt<"bottom"flp><"clear">'
        });
        } );
    </script>

{% endblock %}


{% block body %}
<h2>{% trans " Text Collections Available" %}</h2>
    <div style="width: 100%">
        <table id="col-table" style="width: 90%">
            <thead>
            <tr>
                <th>{% trans "Collection" %}</th>
                <th>{% trans "Size (documents)" %}</th>
                <th>{% trans "Database" %}</th>
            </tr>
            </thead>
            <tbody>
            {% for col,data in collections.items %}
            <tr oncontextmenu="Dajaxice.taw.get_doc_list(my_js_callback,['{{ col }}','{{ data.db }}']);">
                <td ><a href="/taw/collections/{{ data.db }}/{{ col }}/">{{ col }}</a></td>
                <td>{{ data.count }}</td>
                <td>{{ data.db }}</td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
    <script type="text/javascript">
        function my_js_callback(data){
          if(data==Dajaxice.EXCEPTION){
            alert('Error! Something happens!');
          }
          else{
            alert(data.message);
          }
        }
    </script>
{% endblock %}